package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.JyjcBsExpenses;
import com.ruoyi.system.service.IJyjcBsExpensesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 部所分摊情况Controller
 * 
 * @author ruoyi
 * @date 2025-07-13
 */
@RestController
@RequestMapping("/system/JyjcBsExpenses")
public class JyjcBsExpensesController extends BaseController
{
    @Autowired
    private IJyjcBsExpensesService jyjcBsExpensesService;

    /**
     * 查询部所分摊情况列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(JyjcBsExpenses jyjcBsExpenses)
    {
        startPage();
        List<JyjcBsExpenses> list = jyjcBsExpensesService.selectJyjcBsExpensesList(jyjcBsExpenses);
        return getDataTable(list);
    }

    /**
     * 导出部所分摊情况列表
     */
    @PreAuthorize("@ss.hasPermi('system:JyjcBsExpenses:export')")
    @Log(title = "部所分摊情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JyjcBsExpenses jyjcBsExpenses)
    {
        List<JyjcBsExpenses> list = jyjcBsExpensesService.selectJyjcBsExpensesList(jyjcBsExpenses);
        ExcelUtil<JyjcBsExpenses> util = new ExcelUtil<JyjcBsExpenses>(JyjcBsExpenses.class);
        util.exportExcel(response, list, "部所分摊情况数据");
    }

    /**
     * 获取部所分摊情况详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:JyjcBsExpenses:query')")
    @GetMapping(value = "/{year}")
    public AjaxResult getInfo(@PathVariable("year") String year)
    {
        return success(jyjcBsExpensesService.selectJyjcBsExpensesByYear(year));
    }

    /**
     * 新增部所分摊情况
     */
    @PreAuthorize("@ss.hasPermi('system:JyjcBsExpenses:add')")
    @Log(title = "部所分摊情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JyjcBsExpenses jyjcBsExpenses)
    {
        return toAjax(jyjcBsExpensesService.insertJyjcBsExpenses(jyjcBsExpenses));
    }

    /**
     * 修改部所分摊情况
     */
    @PreAuthorize("@ss.hasPermi('system:JyjcBsExpenses:edit')")
    @Log(title = "部所分摊情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JyjcBsExpenses jyjcBsExpenses)
    {
        return toAjax(jyjcBsExpensesService.updateJyjcBsExpenses(jyjcBsExpenses));
    }

    /**
     * 删除部所分摊情况
     */
    @PreAuthorize("@ss.hasPermi('system:JyjcBsExpenses:remove')")
    @Log(title = "部所分摊情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{years}")
    public AjaxResult remove(@PathVariable String[] years)
    {
        return toAjax(jyjcBsExpensesService.deleteJyjcBsExpensesByYears(years));
    }
}
